package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;

/**
 * 生命值一旦低于最大生命值10%时立即死亡(不超过目标攻击力的5倍)
 */
public class 夭折BH extends BuffHandler {

	private double 血量;
	private double 攻击系数;

	//血量=1000&攻击系数=5000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量 = args.getDouble("血量", 0d);
		攻击系数 = args.getWDouble("攻击系数", 0d);
	}

	@Override
	public void onMoveDone(MoveCtx move, TimeActionCtx action) {
		if (buff.owner.isDead()) {
			return;
		}
		if (buff.owner.attr.total().hpCurRate() > 血量) {
			return;
		}
		if (buff.owner.attr.total().hpCur() > buff.owner.attr.attTotal() * 攻击系数) {
			return;
		}
		buff.owner.attr.hpCur(0d);
		buff.owner.checkDead(action, buff.caster);
	}
}
